#include <stdio.h>
int binary_search(int* arr,int x,int length)
{
    int left = 0;
    int right = length - 1;
    int mid = 0;
    while(left <= right)
    {
        mid = (left + right)/2;
        if(arr[mid] > x)
        {
            right = mid - 1;
        }
        else if(arr[mid] < x)
        {
            left = mid + 1;
        }
        else
        {
            return mid;
        }
    }
    return 0;
}


int main()
{
    int app[10] = {1,2,3,4,5,6,7,8,9,10};
    int k = 0;
    int ret = 0;
    int sz = sizeof(app)/sizeof(app[0]);
    scanf("%d", &k);
    //binary-search
    //输入一个数组，一个数，找到下标并返回，若未找到则返回-1
    ret = binary_search(app, k, sz);
    if(ret == -1)
    {
        printf("没有找到\n");
    }
    else
    printf("找到了，下标是%d\n",ret);
    return 0;
}